package lianxi11;

import static lianxi11.Util.delay;

import java.util.Random;

public class Shop {

	private final String name ;
	
	private final Random random ;

	public String getName() {
		return name;
	}

	public Random getRandom() {
		return random;
	}

	public Shop(String name) {
		this.name = name;
		this.random = new Random(name.charAt(0)* name.charAt(1)*name.charAt(2));
	}
	
	public String getPrice(String product){
		double price= calculatePrice(product);
		Discount.Code code =Discount.Code.values()[random.nextInt(Discount.Code.values().length)];
		return name + ":" + price + ":" + code; 
	
	}
	
	private double calculatePrice(String product){
		delay();
		return random.nextDouble()*product.charAt(0)+product.charAt(1);
	}
	
}
